<!doctype html>
<html>
<head>
	<meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1.0"/>
	<meta name="format-detection" content="telephone=no"/>
	<meta charset="utf-8">
	<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"/>
	<meta http-equiv="Pragma" content="no-cache"/>
	<meta http-equiv="Expires" content="0"/>
	<title>抽奖!抽奖!!立得福利！</title>
	<script type="text/javascript" src="{:ADDON_PUBLIC_PATH}/public/js/jquery-1.11.3.min.js"></script>
	<script type="text/javascript" src="{:ADDON_PUBLIC_PATH}/public/js/wScratchPad.js"></script>

	<script type="text/javascript">
		//静态变量
		var IMG_PATH = "__IMG__";
		var STATIC_PATH = "__STATIC__";
		var WX_APPID = "{$jsapiParams.appId}";
		var WXJS_TIMESTAMP = '{$jsapiParams.timestamp}';
		var NONCESTR = '{$jsapiParams.nonceStr}';
		var SIGNATURE = '{$jsapiParams.signature}';
	</script>

	<link rel="stylesheet" type="text/css" href="{:ADDON_PUBLIC_PATH}/public/css/style.css">
	<link rel="stylesheet" type="text/css" href="{:ADDON_PUBLIC_PATH}/ggk/css/ggk.css">
	<script type="text/javascript" src="{:ADDON_PUBLIC_PATH}/ggk/js/ggk.js"></script>

	<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
	<script type="text/javascript"
	        src="minify.php?f=__JS__/prefixfree.min.js,__JS__/m/dialog.js,__JS__/m/flipsnap.min.js,__JS__/m/mobile_module.js"></script>
</head>

<body>
<div class="wait">
	<div class="waitCen">
		<div class="waitBar">
			<div class="waitDh"></div>
		</div>
		<p>人家正在赶来了啦...</p>
	</div>
</div>
<div class="wrapCen">
	<div class="infoCen">
		<img src="{:ADDON_PUBLIC_PATH}/ggk/images/ggk.jpg" class="ggkPic"/>
		<img src="{:ADDON_PUBLIC_PATH}/ggk/images/r_2.png" class="r_0"/>

		<div class="gjBar">
			<php> if ($error) {</php>
			<div class="jxInfo">{$error}</div>
			<div class="gjc" id="gjc"></div>
			<php> } else {</php>
			<div class="jxInfo">{$prize.title}</div>
			<div class="gjc" id="gjc"></div>
			<php> }</php>
		</div>
		<a href="javascript:;" class="zjjlBtn">中奖记录</a>
		<!--<a href="{$zjjl_url}" class="zjjlBtn">中奖记录</a>-->
	</div>
	<!-- 得奖弹窗 -->
	<div class="tcBg ydjTcBg">
		<div class="tc ydjTc">
			<div class="tcCen">
				<div class="ggkDjTitleBar">
					<img src="{:ADDON_PUBLIC_PATH}/ggk/images/ggkDjTitle.png" class="ggkDjPic"/>
				</div>
				<div class="jpInfoBar">{$prize.title}一张</div>
				<div class="infoSrBar">
					<div class="infoSrTishi">亲，留下信物好相见！</div>
					<div class="telInputBar">
						<input id="mobile_card" type="tel" class="telInput" placeholder="请输入正确的手机号码" value=""
						       name="mobile"/>
					</div>
					<!--<div class="telTishiInfo">（请输入正确的手机号码）</div>-->
					<div class="tijiaoBar">
						<a href="javascript:;" class="tijiaoBtn">提交</a>
					</div>
				</div>
				<!-- 备注 -->
				<div class="beiz">
					<h1>备注：</h1>

					<p>商家代金券：</p>

					<p>凭手机号码在星汇两江N37对应商家直接使用(商家开业后三个月内有效）</p>

					<p>N37 500元通用券：</p>

					<p>11月20日-30日，凭电话号码至星汇两江N37招商中心领取</p>

					<p>电话费中奖页面备注：</p>

					<p>11月20日-28日充值到户</p>
				</div>
			</div>
		</div>
	</div>
	<!-- 得奖弹窗结束 -->

	<!-- 未得奖弹窗 -->
	<div class="wdjTcBg wdjTc">
		<div class="wdjTcCen">
			<div class="wdjTcInfoBar">
				<div class="czBar">
					<i class="closeBtn"></i>
				</div>
				<div class="infoTitleBar">
					<img src="{:ADDON_PUBLIC_PATH}/ggk/images/wdjTitleIcon.png" class="infoTitlePic"/>
				</div>
				<div class="info wzjTitle">
					<p>很遗憾未中奖~</p>
				</div>
				<div class="info">
					<a href="javascript:;" class="jxgk">继续刮奖</a>
				</div>
				<div class="info gjjhts">
					<!--<p>还有<font class="prize_count">{$prize.count}</font>次机会！继续加油~</p>-->
					<p>你今天一共只有<font class="prize_count">3</font>次机会！继续加油~</p>
				</div>
			</div>
		</div>
	</div>
	<!-- 未得奖弹窗 结束 -->


	<!-- 提交成功弹窗 -->
	<div class="wdjTcBg tjcgTcBg">
		<div class="wdjTcCen">
			<div class="wdjTcInfoBar">
				<div class="czBar">
					<i class="closeBtn"></i>
				</div>
				<div class="infoTitleBar">
					<img src="{:ADDON_PUBLIC_PATH}/ggk/images/ggkDjTitle_2.png" class="infoTitlePic"/>
				</div>
				<div class="info">
					<a href="javascript:;" class="jxgk">继续刮奖</a>
				</div>
				<div class="info gjjhts">
					<p>还有<font class="prize_count">{$prize.count}</font>次机会！继续加油~</p>
				</div>
			</div>
		</div>
	</div>
	<!-- 提交成功弹窗 结束 -->


	<!-- 二维码弹窗 -->
	<div class="tcBg erweimaTcBg">
		<div class="tc">
			<div class="tcHeader">
				<h1 class="tcHeaderTitle">通知</h1>
				<a href="javascript:;" class="closeBtn"></a>
			</div>
			<div class="tcCenBar">
				<div class="tcTishiInfoBar">
					<p>关注我们即可参与投票！</p>
				</div>
				<div class="erweimaBar">
					<img src="{:ADDON_PUBLIC_PATH}/ggk/images/erweima.png" class="erweimaPic"/>
				</div>
				<div class="saomaBar">
					<div class="saomaCen">
						<i class="saomaTishiPic"></i>

						<div class="saomaWzTishi">
							<span>长按二维码！</span>

							<p>即可关注N37公众微信号</p>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- 二维码弹窗 结束 -->


	<!-- 中奖记录弹窗 -->
	<div class="zjjlTc">
		<div class="infoBar">
			<div class="infoCen">
				<div class="titleBar">
					<img src="{:ADDON_PUBLIC_PATH}/ggk/images/titleIcon.png" class="titleIcon"/>
				</div>
				<div class="listHeader headBar">
					<div class="headerItem">时间</div>
					<div class="headerItem">奖品</div>
					<div class="headerItem">状态</div>
				</div>
				<div class="infoList">

					<volist name="my_prizes" id="vo">
						<!-- 一条数据 -->
						<div class="infoItemCen">
							<div class="infoItem">
								<div class="infoK">{$vo.cTime|time_format}</div>
							</div>
							<div class="infoItem">
								<div class="infoK">{$vo.prize_title}<font>1</font>张</div>
							</div>
							<div class="infoItem">
								<div class="infoK">
									<if condition="$vo.is_use eq 0">未领取
										<else/>
										已领取
									</if>
								</div>
							</div>
						</div>
						<!-- 一条数据 结束 -->
					</volist>

				</div>
			</div>
		</div>
	</div>
	<!-- 中奖记录弹窗 结束 -->


</div>
<script type="text/javascript">
	//微信分享
	$.WeiPHP.initWxShare({
		title: "投我一票 立见福利！",
		imgUrl: "http://magic-cn.com/weixin/N37/Uploads/Picture/sharepic.jpg",
		desc: "500元N37通用券！商家大礼包！10元话费任性送！！你还不来？！",
		link: "{$ggk_url}"
	})
</script>

<script>
	//处理自动更新数据
	$(function () {
		var is_auto_check = {$is_auto_check};
		if (is_auto_check) {
			var url = "{:addons_url('Scratch://Scratch/ajax_edit')}";
			var id = "{$result_next.id}";
			var keyword = '抽奖';
			var title = "{$result_next.title}";
			var use_tips = "{$result_next.use_tips}";
			var end_tips = "{$result_next.end_tips}";
			var start_time = "{$result_next.start_time}";
			var end_time = "{$result_next.end_time}";
			var predict_num = "{$result_next.predict_num}";
			$.post(url, {
				id: id,
				keyword: keyword,
				title: title,
				use_tips: use_tips,
				end_tips: end_tips,
				start_time: start_time,
				end_time: end_time,
				predict_num: predict_num
			}, function (e) {
				if (e.status > 0) {
					alert('亲,你点击的链接早已经过了很久了,数据也需要更新,请不要关闭微信,只需持续点击确定即可');
					window.location.href = "{$next_url}";
				}
				else {
					alert('数据更新失败,请联系管理员手动更新该数据');
				}
			});
		}
	});
</script>


<script>


	// 关闭中奖记录弹窗
	function closeZjjl() {
		var tjcgTcBg_obj = jQuery(".zjjlTc");
		tjcgTcBg_obj.fadeOut();
		tjcgTcBg_obj.find(".infoBar").animate({
			"margin-top": "-140px",
			"opacity": "0"
		}, "slow", function () {
			jQuery(this).css("margin-top", "-240px");
		});
	}
	// 打开中奖记录弹窗
	function operZjjl() {
		var tjcgTcBg_obj = jQuery(".zjjlTc");
		tjcgTcBg_obj.fadeIn();
		tjcgTcBg_obj.find(".infoBar").animate({
			"margin-top": "-190px",
			"opacity": "1"
		}, "slow");
	}

	// 打开二维码弹窗
	function operErweima() {
		jQuery(".erweimaTcBg").fadeIn();
		jQuery(".erweimaTcBg").find(".tc").animate({
			"margin-top": "-161px",
			"opacity": "1"
		}, "slow");
	}

	// 关闭二维码弹窗
	function closeErweima() {
		jQuery(".erweimaTcBg").fadeOut();
		jQuery(".erweimaTcBg").find(".tc").animate({
			"margin-top": "-111px",
			"opacity": "0"
		}, "slow", function () {
			jQuery(this).css("margin-top", "-211px");
		});
	}


	// 刮刮卡
	jQuery(document).ready(function () {
		var imgObj = jQuery("img");
		var imgNum = imgObj.length;
		imgObj.each(function (i, n) {
			var thisObj = jQuery(this);
			jQuery("<img />").attr("src", thisObj.attr("src")).load(function () {
				imgNum--;
				if (imgNum <= 0) {
					jQuery(".wait").animate({
						"top": -jQuery(window).height() + "px"
					}, "slow", function () {
						jQuery(this).remove();
					});
					setW();
					return false;
				}
			});
		});

		// 打开中奖记录弹窗
		jQuery(".zjjlBtn").bind("click", function () {
			operZjjl();
		});

		// 关闭中奖记录弹窗
		jQuery(".zjjlTc").bind("click", function () {
			closeZjjl();
		});
		jQuery(".infoBar").bind("click", function (e) {
			e.stopPropagation();
		});


		//继续抽奖
		$(".jxgk,.closeBtn").click(function () {
			window.location.reload();
		})


		// 设置刮刮卡的宽度
		jQuery(window).resize(function () {
			setW();
		});

		// 关闭未中奖弹窗
		jQuery(".closeBtn").bind("click", function () {
			closeWzj();
		});

		// 打开提交成功弹窗
//		jQuery(".tijiaoBtn").bind("click",function(){
//			closeYzj();
//		});

		// 设置 page 的宽度
		function setW() {
			var w_val = jQuery(".wrapCen").width();
			var gjBar_obj = jQuery(".gjBar");
			var font_size = parseInt(gjBar_obj.find(".jxInfo").css("font-size"));
			var img_w = 640;
			var img_h = 1008;
			var ggk_w = 410;
			var ggk_h = 184;
			var b_num = w_val / img_w;
			var setT = jQuery(".ggkPic").offset().top;
			var img_dang_h = b_num * img_h;
			var ggk_d_w = b_num * ggk_w;
			var ggk_d_h = b_num * ggk_h;
			var topNum = ( 0.362103 * img_dang_h ) + setT;
			gjBar_obj.css({
				"width": ggk_d_w + "px",
				"height": ggk_d_h + "px",
				"top": topNum + "px"
			}).find(".jxInfo").css({
				"font-size": ( font_size * b_num ) + "px"
			});

			// 刮刮卡
			jQuery("#gjc").wScratchPad({
				width: ggk_d_w,
				height: ggk_d_h,
				color: "#b2afac",
				scratchUp: function (e, percent) {
					if (percent > 1) {
						var error = "{$error}";
						if (error.length <= 0  && $('.jxInfo').text() != '奖品已抽完' ) {

							send_sn_code();
							//点解提交
							$(".tijiaoBtn").click(function () {
								if ($("#mobile_card").val() == '' || $("#mobile_card").val == 'undefined') {
									$('.telTishiInfo').html('请输入正确的手机号码,领奖品就靠她!');
								}
								else {
									var url = "{:addons_url('Scratch://Scratch/set_sn_code_prize')}";
									var id = "{$data.id}";
									var prize_id = "{$prize.id}";
									var mobile = $("#mobile_card").val();
									$.post(url, {id: id, prize_id: prize_id, mobile: mobile}, function (e) {
//										if(e > 0)
//										{
										operTjcg();
//										}
									});
									closeYzj();
								}

							});

							var xx_title = "{$prize.title}";
							if (xx_title == '谢谢参与') {
								operWzj();
							}
							else {
								operYzj();
							}
						}
						else if (error == '关注后才能参与')  //判断未关注
						{
							operErweima();
						}
					}
				}
			});
		}

		//发送抽奖次数
		function send_sn_code() {
			var url = "{:addons_url('Scratch://Scratch/set_sn_code')}";
			var id = "{$data.id}";
			var prize_id = "{$prize.id}";
			$.post(url, {id: id, prize_id: prize_id});
		}


		// 打开已中奖
		function operYzj() {
			jQuery(".ydjTcBg").fadeIn();
			jQuery(".ydjTc").animate({
				"margin-top": "-214px",
				"opacity": "1"
			}, "slow");
		}

		// 打开未中奖
		function operWzj() {
			jQuery(".wdjTc").fadeIn();
			jQuery(".wdjTc").find(".wdjTcCen").animate({
				"margin-top": "-112px",
				"opacity": "1"
			}, "slow");
		}

		// 打开提交成功弹窗
		function operTjcg() {
			var tjcgTcBg_obj = jQuery(".tjcgTcBg");
			tjcgTcBg_obj.fadeIn();
			tjcgTcBg_obj.find(".wdjTcCen").animate({
				"margin-top": "-93px",
				"opacity": "1"
			}, "slow");

		}

		// 已中奖弹窗关闭
		function closeYzj() {
			jQuery(".ydjTcBg").fadeOut();
			jQuery(".ydjTc").animate({
				"margin-top": "-164px",
				"opacity": "0"
			}, "slow", function () {
//				operTjcg();	// 打开提交成功弹窗
				jQuery(this).css("margin-top", "-264px");
			});
		}

		// 未中奖弹窗关闭
		function closeWzj() {
			jQuery(".wdjTcBg").fadeOut();
			jQuery(".wdjTcCen").animate({
				"margin-top": "-62px",
				"opacity": "0"
			}, "slow", function () {
				jQuery(this).css("margin-top", "-162px");
			});
		}

		// 提交成功弹窗关闭
		function closeTjcg() {
			var tjcgTcBg_obj = jQuery(".tjcgTcBg");
			tjcgTcBg_obj.fadeOut();
			tjcgTcBg_obj.find(".wdjTcCen").animate({
				"margin-top": "-43px",
				"opacity": "0"
			}, "slow", function () {
				jQuery(this).css("margin-top", "-143px");
			});
		}
	});


</script>

</body>
</html>
